package com.matt.docpro.service;

import com.matt.docpro.mapper.AppointmentMapper;
import com.matt.docpro.mapper.PatientMapper;
import com.matt.docpro.mapper.UserMapper;
import com.matt.docpro.model.Appointment;
import com.matt.docpro.model.Doctor;
import com.matt.docpro.model.Patient;
import com.matt.docpro.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * AppointmentService
 * Created by on 2024/02/20.
 */
@Service
public class PatientService {

    @Autowired
    PatientMapper patientMapper;
    @Autowired
    UserMapper userMapper;

    public List<Patient> getAll() {
        return patientMapper.getAll();
    }

    public Patient getById(String id) {
        return patientMapper.getById(id);
    }

    public int getCount() {
        return patientMapper.getCount();
    }

    public void update(Patient patient) {
        patientMapper.update(patient);
    }

    public void insert(Patient patient) {
        patientMapper.insert(patient);
        User user = new User();
        user.setId(patient.getId());
        user.setPassword("123456");
        user.setAccount(patient.getId());
        user.setMail(patient.getMail());
        user.setBaned(false);
        user.setRole("2");
        userMapper.insert(user);
    }

}
